package com.icare.shop.server.rest;

import com.icare.shop.common.base.ResponseResult;
import com.icare.shop.server.api.ShopService;
import com.icare.shop.server.feign.TradeFeignService;
import com.icare.shop.server.resp.GoodsResp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
 * <pre>
 *    author  : tianhaibo
 *    email   : tianhaibo@jshuii.com
 *    time    : 2020/3/12   20:04
 *    desc    :
 *    version : v1.0
 * </pre>
 */
@Slf4j
@RestController
@RequestMapping("v1")
@Api(tags = "商品",value = "商品")
public class ShopRest {

    @Autowired
    private TradeFeignService tradeService;

    @Autowired
    private ShopService shopService;

    @GetMapping("getShopInfo")
    @ApiOperation("查询商品")
    public ResponseResult<GoodsResp> getShopInfo(@RequestParam("id")Long id){
        GoodsResp goods = shopService.getGoods(id);
        return ResponseResult.success(goods);
    }

    @GetMapping("getGoodsNoTransaction")
    @ApiOperation("查询商品事物")
    public ResponseResult<GoodsResp> getGoodsNoTransaction(@RequestParam("id")Long id){
        GoodsResp goods = shopService.getGoodsNoTransaction(id);
        return ResponseResult.success(goods);
    }

    @GetMapping("getFeignShopInfo")
    @ApiOperation("查询商品")
    public ResponseResult<GoodsResp> getFeignShopInfo(@RequestParam("id")Long id){
        log.info("00{}",id);
        return tradeService.getShopInfo(id);
    }
}
